﻿//初始化参数设置
$(function () {
    //设置标题
    window.TitleName_FieldName = "ct_abbr";
    window.TitleID_FieldName = "ct_user_no";

    //主表字段设置----------------------------------------------------------------------------------------------------------------------------------

    //添加表单时的字段设置
    var AddFields = { OperationKey: "浏览主表", Fields: [
            { ID: "CTAutoID", Type: "Hidden" },
            { ID: "ct_user_no", ShowName: "客户编号", Readonly: false, Required: true, Type: "Text", Width: 100, OperationKey: "筛选客户编号", DataField: "ct_user_no", LineBreak: false },
            { ID: "ct_store_no", ShowName: "门店编号", Readonly: false, Required: false, Type: "Text", Width: 100, OperationKey: "筛选门店编号", DataField: "ct_store_no", LineBreak: false },
            { ID: "ct_abbr", ShowName: "客户简称", Readonly: false, Required: true, Type: "Text", Width: 200, OperationKey: "筛选客户简称", DataField: "ct_abbr", LineBreak: false },
            { ID: "act_date", ShowName: "订单日期", Readonly: false, Required: true, Type: "Date", Width: 100, DefautlValue: "#ToDay", DataField: "act_date", LineBreak: false },
            { ID: "person", ShowName: "制<span> </span>单<span> </span>人", Readonly: true, Required: false, Type: "Text", Width: 100, DefautlValue: "#UserName", DataField: "person", LineBreak: true },
            { ID: "create_date", ShowName: "创建日期", Readonly: true, Required: false, Type: "Text", Width: 100, DefautlValue: "#ToDay", DataField: "create_date", LineBreak: false },
            { ID: "remark", ShowName: "备　　注", Readonly: false, Required: false, Type: "Text", Width: 725, DataField: "remark", LineBreak: true }
        ]
    };
    //等待提交(草稿)时的字段设置    
    var DraftFields = { OperationKey: "浏览主表", Fields: [
            { ID: "voucher_id", ShowName: "系统编号", Readonly: true, Required: false, Type: "Text", Width: "100", DataField: "voucher_id", LineBreak: false },
            { ID: "CTAutoID", Type: "Hidden" },
            { ID: "ct_user_no", ShowName: "客户编号", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ct_user_no", LineBreak: false },
            { ID: "ct_store_no", ShowName: "门店编号", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ct_store_no", LineBreak: false },
            { ID: "ct_abbr", ShowName: "客户简称", Readonly: true, Required: false, Type: "Text", Width: 200, DataField: "ct_abbr", LineBreak: false },
            { ID: "create_date", ShowName: "创建日期", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "create_date", LineBreak: true },
            { ID: "act_date", ShowName: "订单日期", Readonly: true, Required: false, Type: "Text", Width: 100, DefautlValue: "#ToDay", DataField: "act_date", LineBreak: false },
            { ID: "co_no", ShowName: "客户单号", Readonly: false, Required: true, Type: "Text", Width: 200, DataField: "co_no", LineBreak: false },
            { ID: "ds_name", ShowName: "顾客姓名", Readonly: false, Required: true, Type: "Text", Width: 100, DataField: "ds_name", LineBreak: false },
            { ID: "ds_mobile", ShowName: "手　　机", Readonly: false, Required: false, Type: "Text", Width: 100, DataField: "ds_mobile", LineBreak: false },
            { ID: "ds_phone", ShowName: "电　　话", Readonly: false, Required: false, Type: "Text", Width: 100, DataField: "ds_phone", LineBreak: true },
            { ID: "ds_prov", ShowName: "省　　份", Readonly: false, Required: false, Type: "Text", Width: 100, DataField: "ds_prov", LineBreak: false },
            { ID: "ds_city", ShowName: "城　　市", Readonly: false, Required: true, Type: "Text", Width: 100, DataField: "ds_city", LineBreak: false },
            { ID: "ds_addr", ShowName: "地　　址", Readonly: false, Required: true, Type: "Text", Width: 550, DataField: "ds_addr", LineBreak: true },
            { ID: "ds_zip", ShowName: "邮　　编", Readonly: false, Required: false, Type: "Text", Width: 100, DataField: "ds_zip", LineBreak: false },
            { ID: "ds_tr", ShowName: "代垫运费", Readonly: false, Required: true, Type: "Text", Regexp: "/^(\\d*\\.)?\\d+$/", Width: 100, DataField: "ds_tr", LineBreak: false },
            { ID: "order_rec_date", ShowName: "交货日期", Readonly: false, Required: true, Type: "Date", EmptyNull: true, Width: 100, DataField: "order_rec_date", LineBreak: false },
            { ID: "order_cancel_date", ShowName: "取消日期", Readonly: false, Required: false, Type: "Date", EmptyNull: true, Width: 100, DataField: "order_cancel_date", LineBreak: false },
            { ID: "person", ShowName: "制<span> </span>单<span> </span>人", Readonly: true, Required: false, Type: "Text", Width: 200, DataField: "person", LineBreak: true },
            { ID: "remark", ShowName: "备　　注", Readonly: false, Required: false, Type: "Text", Width: 900, DataField: "remark", LineBreak: true },
            { ID: "co_amt", ShowName: "订单金额", Type: "Amount", DataField: "co_amt" }
        ]
    };
    //等待审核(审核)时的字段设置   
    var AuditFields = { OperationKey: "浏览主表", Fields: [
            { ID: "voucher_id", ShowName: "系统编号", Readonly: true, Required: false, Type: "Text", Width: "100", DataField: "voucher_id", LineBreak: false },
            { ID: "CTAutoID", Type: "Hidden" },
            { ID: "ct_user_no", ShowName: "客户编号", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ct_user_no", LineBreak: false },
            { ID: "ct_store_no", ShowName: "门店编号", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ct_store_no", LineBreak: false },
            { ID: "ct_abbr", ShowName: "客户简称", Readonly: true, Required: false, Type: "Text", Width: 200, DataField: "ct_abbr", LineBreak: false },
            { ID: "create_date", ShowName: "创建日期", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "create_date", LineBreak: true },
            { ID: "act_date", ShowName: "订单日期", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "act_date", LineBreak: false },
            { ID: "co_no", ShowName: "客户单号", Readonly: true, Required: false, Type: "Text", Width: 200, DataField: "co_no", LineBreak: false },
            { ID: "ds_name", ShowName: "顾客姓名", Readonly: false, Required: true, Type: "Text", Width: 100, DataField: "ds_name", LineBreak: false },
            { ID: "ds_mobile", ShowName: "手　　机", Readonly: false, Required: false, Type: "Text", Width: 100, DataField: "ds_mobile", LineBreak: false },
            { ID: "ds_phone", ShowName: "电　　话", Readonly: false, Required: false, Type: "Text", Width: 100, DataField: "ds_phone", LineBreak: true },
            { ID: "ds_prov", ShowName: "省　　份", Readonly: false, Required: false, Type: "Text", Width: 100, DataField: "ds_prov", LineBreak: false },
            { ID: "ds_city", ShowName: "城　　市", Readonly: false, Required: true, Type: "Text", Width: 100, DataField: "ds_city", LineBreak: false },
            { ID: "ds_addr", ShowName: "地　　址", Readonly: false, Required: true, Type: "Text", Width: 550, DataField: "ds_addr", LineBreak: true },   
            { ID: "ds_zip", ShowName: "邮　　编", Readonly: false, Required: false, Type: "Text", Width: 100, DataField: "ds_zip", LineBreak: false },
            { ID: "ds_tr", ShowName: "代垫运费", Readonly: false, Required: true, Type: "Text", Regexp: "/^(\\d*\\.)?\\d+$/", Width: 100, DataField: "ds_tr", LineBreak: false },
            { ID: "order_rec_date", ShowName: "交货日期", Readonly: false, Required: true, Type: "Date", EmptyNull: true, Width: 100, DataField: "order_rec_date", LineBreak: false },
            { ID: "order_cancel_date", ShowName: "取消日期", Readonly: false, Required: false, Type: "Date", EmptyNull: true, Width: 100, DataField: "order_cancel_date", LineBreak: false },
            { ID: "person", ShowName: "制<span> </span>单<span> </span>人", Readonly: true, Required: false, Type: "Text", Width: 200, DataField: "person", LineBreak: true },
            { ID: "remark", ShowName: "备　　注", Readonly: false, Required: false, Type: "Text", Width: 900, DataField: "remark", LineBreak: true },
            { ID: "co_amt", ShowName: "订单金额", Type: "Amount", DataField: "co_amt" },
            { ID: "acce_co_amt", ShowName: "确认金额", Type: "ConfirmAmount", DataField: "acce_co_amt" }
        ]
    };
    //等待确认(确认)时的字段设置  
    var ConfirmFields = { OperationKey: "浏览主表", Fields: [
            { ID: "voucher_id", ShowName: "系统编号", Readonly: true, Required: false, Type: "Text", Width: "100", DataField: "voucher_id", LineBreak: false },
            { ID: "CTAutoID", Type: "Hidden" },
            { ID: "ct_user_no", ShowName: "客户编号", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ct_user_no", LineBreak: false },
            { ID: "ct_store_no", ShowName: "门店编号", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ct_store_no", LineBreak: false },
            { ID: "ct_abbr", ShowName: "客户简称", Readonly: true, Required: false, Type: "Text", Width: 200, DataField: "ct_abbr", LineBreak: false },
            { ID: "create_date", ShowName: "创建日期", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "create_date", LineBreak: true },
            { ID: "act_date", ShowName: "订单日期", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "act_date", LineBreak: false },
            { ID: "co_no", ShowName: "客户单号", Readonly: true, Required: false, Type: "Text", Width: 200, DataField: "co_no", LineBreak: false },
            { ID: "ds_name", ShowName: "顾客姓名", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_name", LineBreak: false },
            { ID: "ds_mobile", ShowName: "手　　机", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_mobile", LineBreak: false },
            { ID: "ds_phone", ShowName: "电　　话", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_phone", LineBreak: true },
            { ID: "ds_prov", ShowName: "省　　份", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_prov", LineBreak: false },
            { ID: "ds_city", ShowName: "城　　市", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_city", LineBreak: false },
            { ID: "ds_addr", ShowName: "地　　址", Readonly: true, Required: false, Type: "Text", Width: 550, DataField: "ds_addr", LineBreak: true },    
            { ID: "ds_zip", ShowName: "邮　　编", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_zip", LineBreak: false },
            { ID: "ds_tr", ShowName: "代垫运费", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_tr", LineBreak: false },
            { ID: "order_rec_date", ShowName: "交货日期", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "order_rec_date", LineBreak: false },
            { ID: "order_cancel_date", ShowName: "取消日期", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "order_cancel_date", LineBreak: false },
            { ID: "person", ShowName: "制<span> </span>单<span> </span>人", Readonly: true, Required: false, Type: "Text", Width: 200, DataField: "person", LineBreak: true },
            { ID: "remark", ShowName: "备　　注", Readonly: false, Required: false, Type: "Text", Width: 900, DataField: "remark", LineBreak: true },
            { ID: "co_amt", ShowName: "订单金额", Type: "Amount", DataField: "co_amt" },
            { ID: "acce_co_amt", ShowName: "确认金额", Type: "ConfirmAmount", DataField: "acce_co_amt" }
        ]
    };
    //已经确认的字段设置 
    var ViewFields = { OperationKey: "浏览主表", Fields: [
            { ID: "voucher_id", ShowName: "系统编号", Readonly: true, Required: false, Type: "Text", Width: "100", DataField: "voucher_id", LineBreak: false },
            { ID: "CTAutoID", Type: "Hidden" },
            { ID: "ct_user_no", ShowName: "客户编号", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ct_user_no", LineBreak: false },
            { ID: "ct_store_no", ShowName: "门店编号", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ct_store_no", LineBreak: false },
            { ID: "ct_abbr", ShowName: "客户简称", Readonly: true, Required: false, Type: "Text", Width: 200, DataField: "ct_abbr", LineBreak: false },
            { ID: "create_date", ShowName: "创建日期", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "create_date", LineBreak: true },
            { ID: "act_date", ShowName: "订单日期", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "act_date", LineBreak: false },
            { ID: "co_no", ShowName: "客户单号", Readonly: true, Required: false, Type: "Text", Width: 200, DataField: "co_no", LineBreak: false },
            { ID: "ds_name", ShowName: "顾客姓名", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_name", LineBreak: false },
            { ID: "ds_mobile", ShowName: "手　　机", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_mobile", LineBreak: false },
            { ID: "ds_phone", ShowName: "电　　话", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_phone", LineBreak: true },
            { ID: "ds_prov", ShowName: "省　　份", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_prov", LineBreak: false },
            { ID: "ds_city", ShowName: "城　　市", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_city", LineBreak: false },
            { ID: "ds_addr", ShowName: "地　　址", Readonly: true, Required: false, Type: "Text", Width: 550, DataField: "ds_addr", LineBreak: true }, 
            { ID: "ds_zip", ShowName: "邮　　编", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_zip", LineBreak: false },
            { ID: "ds_tr", ShowName: "代垫运费", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "ds_tr", LineBreak: false },
            { ID: "order_rec_date", ShowName: "交货日期", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "order_rec_date", LineBreak: false },
            { ID: "order_cancel_date", ShowName: "取消日期", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "order_cancel_date", LineBreak: false },
            { ID: "person", ShowName: "制<span> </span>单<span> </span>人", Readonly: true, Required: false, Type: "Text", Width: 100, DataField: "person", LineBreak: true },
            { ID: "remark", ShowName: "备　　注", Readonly: true, Required: false, Type: "Text", Width: 200, DataField: "remark", LineBreak: true },
            { ID: "co_amt", ShowName: "订单金额", Type: "Amount", DataField: "co_amt" },
            { ID: "acce_co_amt", ShowName: "确认金额", Type: "ConfirmAmount", DataField: "acce_co_amt" }
        ]
    };

    //从表字段设置----------------------------------------------------------------------------------------------------------------------------------

    //选择列表的字段设置(只有草稿状态时才需要该行)  
    window.SelectDetail = [
        { display: '自动编号', name: 'AutoID', width: 50, sortable: true, align: 'left', hide: true },
        { display: 'SKU号', name: 'pd_st_id', width: 80, sortable: true, align: 'left', hide: false },
        { display: '货号', name: 'pd_id', width: 50, sortable: true, align: 'left', hide: false },
        { display: '名称', name: 'pd_cn_name', width: 120, sortable: true, align: 'left', hide: false },
        { display: '规格', name: 'pd_cn_spec', width: 90, sortable: true, align: 'left', hide: false },
        { display: '单位', name: 'uom', width: 25, sortable: true, align: 'left', hide: true },
        { display: '数量', name: 'co_qty', width: 55, sortable: true, align: 'right', hide: true, InputType: "Text", InputCalss: "Required", Regexp: "/^\\d+$/", RegexpError: "输入格式错误，当前输入必须是正整数！", AutoMath: "window.DetailMath" },
        { display: '单价', name: 'co_price', width: 65, sortable: true, align: 'right', hide: false },
        { display: '操作', name: 'Operation', width: 25, sortable: false, align: 'left', hide: false }
    ];
    //明细选择行的字段设置(只有草稿状态时才需要该行) 
    var DetailSelect = [
        { display: '自动编号', name: 'AutoID', width: 50, align: 'left', hide: true, InputType: null },
        { display: '序号', name: 'line_no', width: 25, align: 'left', hide: true, InputType: null },
        { display: 'SKU号', name: 'pd_st_id', width: 80, align: 'left', hide: false, InputType: null },
        { display: '货号', name: 'pd_id', width: 50, align: 'left', hide: false, InputType: null },
        { display: '名称', name: 'pd_cn_name', width: 160, align: 'left', hide: true, InputType: null },
        { display: '规格', name: 'pd_cn_spec', width: 99, align: 'left', hide: false, InputType: null },
        { display: '单位', name: 'uom', width: 25, align: 'left', hide: true, InputType: null },
        { display: '数量', name: 'co_qty', width: 55, align: 'right', hide: true, InputType: "Text", InputCalss: "Required", Regexp: "/^\\d+$/", RegexpError: "输入格式错误，当前输入必须是正整数！", AutoMath: "window.DetailMath" },
        { display: '单价', name: 'co_price', width: 65, align: 'right', hide: false, InputType: null },
        { display: '金额', name: 'co_amt', width: 81, align: 'right', hide: true, InputType: null },
        { display: '备注', name: 'remark', width: 80, align: 'left', hide: true, InputType: "Text" },
        { display: '操作', name: 'Operation', width: 25, align: 'left', hide: false, InputType: null }
    ];
    //自动完成行的字段设置(只有草稿状态时才需要该行)                  
    var DetailAuto = [
        { name: '', width: 50, align: 'left', hide: true, InputType: null },
        { name: '', width: 25, align: 'left', hide: false, InputType: null },
        { name: 'pd_st_id', width: 100, align: 'left', hide: false, InputType: "Text", InputID: "Auto_ct_pd_id", InputCalss: "Select", OperationKey: "筛选产品SKU" },
        { name: 'pd_id', width: 60, align: 'left', hide: false, InputType: "Text", InputID: "Auto_pd_id", InputCalss: "Select", OperationKey: "筛选产品货号" },
        { name: 'pd_cn_name', width: 160, align: 'left', hide: false, InputType: "Text", InputID: "Auto_pd_cn_name", InputCalss: "Select", OperationKey: "筛选产品名称" },
        { name: 'pd_cn_spec', width: 120, align: 'left', hide: false, InputType: "Text", InputID: "Auto_pd_cn_spec", InputCalss: "Select", OperationKey: "筛选产品型号" },
        { name: '', width: 25, align: 'left', hide: false, InputType: null },
        { name: '', width: 55, align: 'right', hide: false, InputType: null },
        { name: '', width: 65, align: 'right', hide: false, InputType: null },
        { name: '', width: 81, align: 'right', hide: false, InputType: null },
        { name: '', width: 80, align: 'left', hide: false, InputType: null },
        { name: '', width: 25, align: 'left', hide: false, InputType: null }
    ];
    //等待提交(草稿)时的字段设置
    var DraftDetailCols = [
        { display: '自动编号', name: 'AutoID', width: 50, align: 'left', hide: true, InputType: null },
        { display: '序号', name: 'line_no', width: 25, align: 'left', hide: false, InputType: null },
        { display: 'SKU号', name: 'pd_st_id', width: 100, align: 'left', hide: false, InputType: null },
        { display: '货号', name: 'pd_id', width: 60, align: 'left', hide: false, InputType: null },
        { display: '名称', name: 'pd_cn_name', width: 160, align: 'left', hide: false, InputType: null },
        { display: '规格', name: 'pd_cn_spec', width: 120, align: 'left', hide: false, InputType: null },
        { display: '单位', name: 'uom', width: 25, align: 'left', hide: false, InputType: null },
        { display: '数量', name: 'co_qty', width: 55, align: 'right', hide: false, InputType: "Text", InputCalss: "Required", Regexp: "/^\\d+$/", RegexpError: "输入格式错误，当前输入必须是正整数！", AutoMath: "window.DetailMath" },
        { display: '单价', name: 'co_price', width: 65, align: 'right', hide: false, InputType: null },
        { display: '金额', name: 'co_amt', width: 81, align: 'right', hide: false, InputType: null },
        { display: '备注', name: 'remark', width: 80, align: 'left', hide: false, InputType: "Text" },
        { display: '操作', name: 'Operation', width: 25, align: 'left', hide: false, InputType: null }
    ];
    //等待审核(审核)时的字段设置   
    var AuditDetailCols = [
        { display: '自动编号', name: 'AutoID', width: 50, align: 'left', hide: true, InputType: null },
        { display: '序号', name: 'line_no', width: 25, align: 'left', hide: false, InputType: null },
        { display: 'SKU号', name: 'pd_st_id', width: 67, align: 'left', hide: false, InputType: null },
        { display: '货号', name: 'pd_id', width: 50, align: 'left', hide: false, InputType: null },
        { display: '名称', name: 'pd_cn_name', width: 100, align: 'left', hide: false, InputType: null },
        { display: '规格', name: 'pd_cn_spec', width: 70, align: 'left', hide: false, InputType: null },
        { display: '单位', name: 'uom', width: 25, align: 'left', hide: false, InputType: null },
        { display: '数量', name: 'co_qty', width: 45, align: 'right', hide: false, InputType: null },
        { display: '确认数量', name: 'acce_qty', width: 50, align: 'right', hide: false, InputType: "Text", InputCalss: "Required", Regexp: "/^\\d+$/", RegexpError: "输入格式错误，当前输入必须是正整数！", AutoMath: "window.DetailMath" },
        { display: '单价', name: 'co_price', width: 65, align: 'right', hide: false, InputType: null },
        { display: '确认单价', name: 'qa_price', width: 65, align: 'right', hide: false, InputType: null },
        { display: '金额', name: 'co_amt', width: 75, align: 'right', hide: false, InputType: null },
        { display: '确认金额', name: 'acce_co_amt', width: 75, align: 'right', hide: false, InputType: null },
        { display: '备注', name: 'remark', width: 60, align: 'left', hide: false, InputType: "Text" }
    ];
    //等待确认(确认)时的字段设置  
    var ConfirmDetailCols = [
        { display: '自动编号', name: 'AutoID', width: 50, align: 'left', hide: true, InputType: null },
        { display: '序号', name: 'line_no', width: 25, align: 'left', hide: false, InputType: null },
        { display: 'SKU号', name: 'pd_st_id', width: 70, align: 'left', hide: false, InputType: null },
        { display: '货号', name: 'pd_id', width: 50, align: 'left', hide: false, InputType: null },
        { display: '名称', name: 'pd_cn_name', width: 100, align: 'left', hide: false, InputType: null },
        { display: '规格', name: 'pd_cn_spec', width: 70, align: 'left', hide: false, InputType: null },
        { display: '单位', name: 'uom', width: 25, align: 'left', hide: false, InputType: null },
        { display: '数量', name: 'co_qty', width: 45, align: 'right', hide: false, InputType: null },
        { display: '确认数量', name: 'acce_qty', width: 47, align: 'right', hide: false, InputType: null },
        { display: '单价', name: 'co_price', width: 65, align: 'right', hide: false, InputType: null },
        { display: '确认单价', name: 'qa_price', width: 65, align: 'right', hide: false, InputType: null },
        { display: '金额', name: 'co_amt', width: 75, align: 'right', hide: false, InputType: null },
        { display: '确认金额', name: 'acce_co_amt', width: 75, align: 'right', hide: false, InputType: null },
        { display: '备注', name: 'remark', width: 60, align: 'left', hide: false, InputType: "Text" }
    ];
    //已经确认的字段设置
    var ViewDetailCols = [
        { display: '自动编号', name: 'AutoID', width: 50, align: 'left', hide: true, InputType: null },
        { display: '序号', name: 'line_no', width: 25, align: 'left', hide: false, InputType: null },
        { display: 'SKU号', name: 'pd_st_id', width: 70, align: 'left', hide: false, InputType: null },
        { display: '货号', name: 'pd_id', width: 50, align: 'left', hide: false, InputType: null },
        { display: '名称', name: 'pd_cn_name', width: 100, align: 'left', hide: false, InputType: null },
        { display: '规格', name: 'pd_cn_spec', width: 70, align: 'left', hide: false, InputType: null },
        { display: '单位', name: 'uom', width: 25, align: 'left', hide: false, InputType: null },
        { display: '数量', name: 'co_qty', width: 45, align: 'right', hide: false, InputType: null },
        { display: '确认数量', name: 'acce_qty', width: 47, align: 'right', hide: false, InputType: null },
        { display: '单价', name: 'co_price', width: 65, align: 'right', hide: false, InputType: null },
        { display: '确认单价', name: 'qa_price', width: 65, align: 'right', hide: false, InputType: null },
        { display: '金额', name: 'co_amt', width: 75, align: 'right', hide: false, InputType: null },
        { display: '确认金额', name: 'acce_co_amt', width: 75, align: 'right', hide: false, InputType: null },
        { display: '备注', name: 'remark', width: 60, align: 'left', hide: false, InputType: null }
    ];

    //各种状态的显示设置----------------------------------------------------------------------------------------------------------------------------------

    var NewShowHidden = { Show: [], Hidden: ["acce_co_amtDiv", "co_amtDiv"] };
    var DraftShowHidden = { Show: ["co_amtDiv"], Hidden: ["acce_co_amtDiv"] };
    var AuditShowHidden = { Show: ["acce_co_amtDiv", "co_amtDiv"], Hidden: [] };
    var ConfirmShowHidden = { Show: ["acce_co_amtDiv", "co_amtDiv"], Hidden: [] };
    var ViewShowHidden = { Show: ["acce_co_amtDiv", "co_amtDiv"], Hidden: [] };

    //自动生成设置----------------------------------------------------------------------------------------------------------------------------------

    var AutoMaster = [{ ObjID: ["ct_user_no", "ct_store_no", "ct_abbr"], DropDownPosition: "ct_user_no", FillTo: ["CTAutoID", "ct_user_no", "ct_store_no", "ct_abbr"], DropDownWidth: 549, AutoLinkChange: true, EmptyObj: false}];
    var AutoDetail = [{ ObjID: ["Auto_ct_pd_id", "Auto_pd_id", "Auto_pd_cn_name", "Auto_pd_cn_spec"], FillTo: [2, 3, 4, 5, 6, 8], DropDownPosition: "Auto_ct_pd_id", Parameters: { "@ct_user_no": "ct_user_no" }, PositionPanel: "ListDetail", PositionDownNum: 5, SelectAutoComplete: SelectDetailAutoComplete, DropDownWidth: 473, EmptyObj: true}];

    //自动计算参数----------------------------------------------------------------------------------------------------------------------------------

    var DraftMath = [{ Type: "Row", Formula: "co_qty * co_price", Value: "co_amt", FixLength: 2 }, { Type: "ColSum", ListID: "ListDetail", ColName: "co_amt", Value: "co_amt", FixLength: 2}];
    var AuditMath = [{ Type: "Row", Formula: "acce_qty * qa_price", Value: "acce_co_amt", FixLength: 2, Compare: "acce_qty <= co_qty", ErrorText:"确认数量必须少于或等于数量" }, { Type: "ColSum", ListID: "ListDetail", ColName: "acce_co_amt", Value: "acce_co_amt", FixLength: 2}];
    var ConfirmMath = [];

    //选择列表参数----------------------------------------------------------------------------------------------------------------------------------

    window.SelectListParameters = { "@ct_user_no": "ct_user_no" };
    window.SelectLinkFiledNames = ["pd_st_id", "pd_id"];
    window.ShowHiddCols = [1, 4, 6, 7, 9, 10];
    window.OpenWidthCols = [{ Index: 2, Width: 80 }, { Index: 3, Width: 50 }, { Index: 5, Width: 99}];
    window.CloseWidthCols = [{ Index: 2, Width: 100 }, { Index: 3, Width: 60 }, { Index: 5, Width: 120}];

    //提交操作参数----------------------------------------------------------------------------------------------------------------------------------

    //检查开始结束时间
    window.CheckDate = [{ StartDate: "act_date" }, { StartDate: "order_rec_date" }, { StartDate: "order_cancel_date"}];

    //下一步操作参数
    window.NextStepParameter = { "@CTAutoID": "CTAutoID", "@act_date": "act_date", "@remark": "remark" };
    //保存草稿操作参数
    window.SaveDraftParameter = { "@co_no": "co_no", "@ds_name": "ds_name", "@ds_mobile": "ds_mobile", "@ds_phone": "ds_phone", "@ds_prov": "ds_prov", "@ds_city": "ds_city", "@ds_addr": "ds_addr", "@ds_zip": "ds_zip", "@ds_tr": "ds_tr", "@order_rec_date": "order_rec_date", "@order_cancel_date": "order_cancel_date", "@remark": "remark" };
    //保存审核操作参数
    window.SaveAuditParameter = { "@ds_name": "ds_name", "@ds_mobile": "ds_mobile", "@ds_phone": "ds_phone", "@ds_prov": "ds_prov", "@ds_city": "ds_city", "@ds_addr": "ds_addr", "@ds_zip": "ds_zip", "@ds_tr": "ds_tr", "@order_rec_date": "order_rec_date", "@order_cancel_date": "order_cancel_date", "@remark": "remark" };
    //保存确认操作参数
    window.SaveConfirmParameter = { "@remark": "remark" };
    //提交草稿操作参数
    window.SubmitDraftParameter = window.SaveDraftParameter;
    //提交草稿操作参数
    window.SubmitAuditParameter = window.SaveAuditParameter;
    //提交草稿操作参数
    window.SubmitConfirmParameter = window.SaveConfirmParameter;
    //撤销审核操作参数
    window.CancelAuditParameter = window.SaveAuditParameter;
    //撤销确认操作参数
    window.CancelConfirmParameter = window.SaveConfirmParameter;

    //添加草稿从表参数
    window.AddDraftDetail = { "@line_no": "line_no", "@pd_st_id": "pd_st_id", "@pd_id": "pd_id", "@pd_cn_name": "pd_cn_name", "@pd_cn_spec": "pd_cn_spec", "@uom": "uom", "@co_qty": "co_qty", "@co_price": "co_price", "@remark": "remark" };
    //删除草稿从表参数
    window.DeleteDraftDetail = { "@AutoID": "AutoID" };
    //修改草稿从表参数
    window.SaveDraftDetail = { "@AutoID": "AutoID", "@co_qty": "co_qty", "@remark": "remark" };
    //修改审核从表参数
    window.SaveAuditDetail = { "@AutoID": "AutoID", "@acce_qty": "acce_qty", "@remark": "remark" };
    //修改确认从表参数
    window.SaveConfirmDetail = { "@AutoID": "AutoID", "@remark": "remark" };

    //逻辑处理初始化参数----------------------------------------------------------------------------------------------------------------------------------

    window.AutoCompletes = new Array();
    if (JsonOriginal.KeyList["KeyA"] == "-1") {
        //添加表单时的参数设置               
        window.Fields = AddFields;
        window.AutoCompletes = window.AutoCompletes.concat(AutoMaster);
        window.ShowHiddenIt = NewShowHidden;
    } else {
        //修改表单时的参数设置  
        //处理不同状态    
        switch (JsonOriginal.Operations["浏览主表"].OperationData[0]["status"]) {
            case "1":
                //等待提交(草稿)                
                if (HasPermission("草稿") && HasCurrentUser(JsonOriginal.Operations["浏览主表"].OperationData[0]["personID"])) {
                    //修改权限时的参数
                    window.Fields = DraftFields;
                    window.ListDetailCols = DraftDetailCols;
                    window.ListDetailAuto = DetailAuto;
                    window.ListDetailSelect = DetailSelect;
                    window.AutoCompletes = window.AutoCompletes.concat(AutoDetail);
                } else {
                    //浏览权限时的参数   
                    window.Fields = ReadonlyFileds(DraftFields);
                    window.ListDetailCols = ReadonlyCols(DraftDetailCols);
                }
                window.ShowHiddenIt = DraftShowHidden;
                window.DetailMath = DraftMath;
                break;
            case "2":
                //等待审核(审核)         
                if (HasPermission("审核")) {
                    //修改权限时的参数
                    window.Fields = AuditFields;
                    window.ListDetailCols = AuditDetailCols;
                } else {
                    //浏览权限时的参数      
                    window.Fields = ReadonlyFileds(AuditFields);
                    window.ListDetailCols = ReadonlyCols(AuditDetailCols);
                }
                window.ShowHiddenIt = AuditShowHidden;
                window.DetailMath = AuditMath;
                break;
            case "3":
                //等待确认(确认)  
                if (HasPermission("确认")) {
                    //修改权限时的参数
                    window.Fields = ConfirmFields;
                    window.ListDetailCols = ConfirmDetailCols;
                } else {
                    //浏览权限时的参数       
                    window.Fields = ReadonlyFileds(ConfirmFields);
                    window.ListDetailCols = ReadonlyCols(ConfirmDetailCols);
                }
                window.ShowHiddenIt = ConfirmShowHidden;
                window.DetailMath = ConfirmMath;
                break;
            case "4":
                //已经确认(最终状态)                  
                window.Fields = ViewFields;
                window.ListDetailCols = ViewDetailCols;
                window.ShowHiddenIt = ViewShowHidden;
                window.ReadOnly = true;
                break;
        }
    }

    //运行初始化方法
    InIt();
}); 